package com.itheima.Test02;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Demo服务器端02 {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(8899);
        Socket s = ss.accept();
        //先创建一个网络输入流;
        InputStream is = s.getInputStream();
        //创建一个输出流;
        FileOutputStream fis = new FileOutputStream("C:\\Users\\97622\\Desktop\\123.docx");
        //写入数据;
        byte[] arr  = new byte[1024];
        int i ;
        while ((i=is.read(arr))!=-1){
            fis.write(arr);
        }
        //创建输出流;
        OutputStream oss = s.getOutputStream();
        oss.write("上传成功".getBytes());
        s.close();
        is.close();
        fis.close();
    }
}
